// #include <SECore/ResManager.h>
#include <SERender/Resourses/Material.h>
#include <SERender/Resourses/Loader/ShaderLoader.h>
#include <SERender/Resourses/Loader/UniformBufferLoader.h>
#include <SERender/Resourses/Loader/TextureLoader.h>
#include <SEngine/Render/Entity/Loader/ModelLoader.h>
#include <SEngine/Render/Entity/Loader/TypeLoader.h>
#include <SECore/Manager.h>
#include <sstream>
#include <fstream>
#include <SEngine/Render/RenderFeature/UBORenderFeature.h>

namespace SEngine
{

    const std::string root = "../../Engine";

    void ResShaderInit() {
        ShaderLoader loader;
        Manager::GetInstance().Register("Shader_Line", loader.Load(root + "/Shader/Line.glsl").CreateShader(EngineUniformBlockBinder()));
        Manager::GetInstance().Register("Shader_Grid", loader.Load(root + "/Shader/Grid.glsl").CreateShader(EngineUniformBlockBinder()));
        Manager::GetInstance().Register("Shader_Lambert", loader.Load(root + "/Shader/Lambert.glsl").CreateShader(EngineUniformBlockBinder()));
        Manager::GetInstance().Register("Shader_Contour", loader.Load(root + "/Shader/Contour.glsl").CreateShader(EngineUniformBlockBinder()));
        Manager::GetInstance().Register("Shader_ColorID", loader.Load(root + "/Shader/ColorID.glsl").CreateShader(EngineUniformBlockBinder()));
        Manager::GetInstance().Register("Shader_Gizmo", loader.Load(root + "/Shader/Gizmo.glsl").CreateShader(EngineUniformBlockBinder()));
        Manager::GetInstance().Register("Shader_Image", loader.Load(root + "/Shader/Image.glsl").CreateShader(EngineUniformBlockBinder()));
        Manager::GetInstance().Register("Shader_Text", loader.Load(root + "/Shader/Text.glsl").CreateShader(EngineUniformBlockBinder()));
        Manager::GetInstance().Register("Shader_Standard", loader.Load(root + "/Shader/Standard.glsl").CreateShader(EngineUniformBlockBinder()));
        Manager::GetInstance().Register("Shader_Unlit", loader.Load(root + "/Shader/Unlit.glsl").CreateShader(EngineUniformBlockBinder()));
        Manager::GetInstance().Register("Shader_Skybox", loader.Load(root + "/Shader/Skybox.glsl").CreateShader(EngineUniformBlockBinder()));
    }
    void ResModelInit() {
        {
            ModelLoader loader(Manager::GetInstance().Get<std::shared_ptr<Shader>>("Shader_Gizmo").value());
            Manager::GetInstance().Register("Model_Sphere", std::shared_ptr<Model>(loader.CreateModel(root + "/Model/Gizmo/Sphere.fbx")));
            Manager::GetInstance().Register("Model_ArrowTranslate", std::shared_ptr<Model>(loader.CreateModel(root + "/Model/Gizmo/Arrow_Translate.fbx")));
        }
        {
            ModelLoader loader(Manager::GetInstance().Get<std::shared_ptr<Shader>>("Shader_Lambert").value());
            Manager::GetInstance().Register("Model_Sphere_Lambert", std::shared_ptr<Model>(loader.CreateModel(root + "/Model/Gizmo/Sphere.fbx")));
        }
    }
    void ResFontInit() {
        Manager::GetInstance().Register("Font_RudaBold", std::make_shared<Font>(root + "/Fonts/Ruda-Bold.ttf"));
    }
    void ResTextureInit() {
        TextureLoader<Texture2D> texLoader;
        Manager::GetInstance().Register("Texture_PointLight", std::shared_ptr<Texture>(texLoader.CreateTexture(root + "/Image/PointLight.png")));
        Manager::GetInstance().Register("Texture_DirectLight", std::shared_ptr<Texture>(texLoader.CreateTexture(root + "/Image/DirectLight.png")));
        Manager::GetInstance().Register("Texture_Camera", std::shared_ptr<Texture>(texLoader.CreateTexture(root + "/Image/Camera.png")));
    }
    // void ResMaterialInit() {
    //     auto material = std::make_shared<Material>();
    //     std::ifstream file(root + "/Materials/Default.semat");
    //     std::stringstream ss;
    //     if (file.is_open()) {
    //         ss << file.rdbuf();
    //         file.close();
    //     }
    //     material->Deserialize(ss.str());
    //     Manager::GetInstance().Register("Material_Default", std::move(material));
    // }
} // namespace SEngine

